package com.lanchetech.dao;

import com.lanchetech.entity.UserAddress;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;import org.apache.ibatis.annotations.Param;

@Mapper
public interface UserAddressMapper {
    int deleteByPrimaryKey(Long id);

    int insert(UserAddress record);

    int insertSelective(UserAddress record);

    UserAddress selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(UserAddress record);

    int updateByPrimaryKey(UserAddress record);

    int updateBatchSelective(List<UserAddress> list);

    UserAddress findOneByIdAndUserId(@Param("id") Long id, @Param("userId") Long userId);

    /**
     * 获取用户主地址，按main排序，如果没有main，则按创建时间排序，获取第1条
     *
     * @param userId
     * @return
     */
    UserAddress findOneMainUserAddress(@Param("userId") Long userId);

    List<UserAddress> findAllByUserId(@Param("userId") Long userId);

    Long countByUserId(@Param("userId") Long userId);

    int resetMain(@Param("userId") Long userId);

    int deleteByIdAndUserId(@Param("id") Long id, @Param("userId") Long userId);

}